﻿import multiprocessing
import time

class MyClass(object):
    
    def __init__(self, name):
        self.name = name
    
    def do_something(self):
        proc_name = multiprocessing.current_process().name
        time.sleep(5)
        print ('Doing something fancy in %s for %s!' % (proc_name, self.name))


def worker(q):
    obj = q.get()
    obj.do_something()


if __name__ == '__main__':
    queue = multiprocessing.Queue()

    p = multiprocessing.Process(target=worker, args=(queue,))
    p.start()
    p2 = multiprocessing.Process(target=worker, args=(queue,))
    p2.start()
    
    queue.put(MyClass('AAA'))
    queue.put(MyClass('BBB')) 
    